package br.uff.busuffweb.model;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author jthiago
 */
@NamedQueries({
    @NamedQuery(name = "Ponto.getTodos",
    query = "select p from Ponto p order by p.id"),
    
    @NamedQuery(name = "Ponto.getPorLatitude",
    query = "select p from Ponto p " +
            " where p.latitude = ?"),
    
    @NamedQuery(name = "Ponto.getPorLongitude",
    query = "select p from Ponto p " +
            " where p.longitude = ?"),
    
    @NamedQuery(name = "Ponto.getPorLatitudeELongitude",
    query = "select p from Ponto p " +
            " where p.latitude = ? and p.longitude = ?")
})
@Entity
@SequenceGenerator(sequenceName = "seq_ponto", name = "Sequencia")
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "ponto")
public class Ponto implements Serializable {
    
    @Id
    @GeneratedValue(generator = "Sequencia", strategy = GenerationType.AUTO)
    private Long id;
    
    private double latitude;
    
    private double longitude;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 37 * hash + (int) (Double.doubleToLongBits(this.latitude) ^ (Double.doubleToLongBits(this.latitude) >>> 32));
        hash = 37 * hash + (int) (Double.doubleToLongBits(this.longitude) ^ (Double.doubleToLongBits(this.longitude) >>> 32));
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Ponto other = (Ponto) obj;
        if (Double.doubleToLongBits(this.latitude) != Double.doubleToLongBits(other.latitude)) {
            return false;
        }
        if (Double.doubleToLongBits(this.longitude) != Double.doubleToLongBits(other.longitude)) {
            return false;
        }
        return true;
    }
}
